#include <stdio.h>
int mySqrt(int x)
{
	if (x == 0)
		return 0;

	signed int i = 1, j;
	do
	{
		printf("%d\n", i);
		j = x / i;
		if (j == i || j < i)
			return j;

		if (j > i)
			i++;
	}
	while (j > i);
	return -1;
}

int main()
{
	printf("%d\n", mySqrt(8));
	printf("%d", mySqrt(2147483647));

}
